<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    // 收件人
    function addressee(n){
        this.name = n;
    }

    // 发件人
    function from(obj){
        this.name = "李四";
        this.send = function(msg){
            console.log(`你好${obj.name}，这是我送你的${msg}`);
        }
    }

    function proxy(obj){
        this.msg = [];
        const f = new from(obj);
        this.send = function(msg){
            // 拦截数据另做他用的阶段
            this.msg.push({
                from: f.name,
                to: obj.name,
                msg: msg,
                time: Date.now()
            })

            f.send(msg);
        }
    }

    
    const a = new addressee("张三");

    const p = new proxy( a );
    p.send("手机");

    console.log(p);

   
</script>
</html>